import Vue from 'vue'
import router from "@/router";
import {
    apiUser
} from "@/api/user/baseinfo"
export function getPremission(toolButtons) {
    Vue.prototype.$itsoftUI.getUserInfo().then(res => {
        // let authorize = JSON.parse(res.auth)
        // let roles = authorize.filter(item => item.systemcode === router.options.code)[0]
        // if (roles) {
        //     roles = JSON.parse(roles.authorize)
        // }
        // toolButtons.filter(item => item.auth).forEach(function (btn) {
        //     btn.disabled = roles.indexOf(btn.auth)<0
        // })
        let systemcode = "apartment"
        let schoolCode = Vue.prototype.$itsoftUI.config.schoolCode
        apiUser.userRolesAuthorizeList(systemcode, res.id, schoolCode).then(res => {
            let roles = JSON.parse(res.data[0].authorize)
            toolButtons.filter(item => item.auth).forEach(function(btn) {
                Vue.set(btn, "disabled", roles.indexOf(btn.auth) < 0)
            })
        })
    });
}